< previous page page_55 next page >

Page 55
Chapter 2
Using the API
Windows programming has long been a difficult task. If you do not get every detail just right, your program can crash spectacularly, sometimes bringing down the operating system as well. If you do not manage system resources properly, your program might ''leak," using more and more resources over time. Eventually, your program might use so many resources that other programs will be unable to run and your system will grind to a halt.
By freeing you from most of the worries of Windows programming, Visual Basic protects you from these dangers. It allows you to program quickly and safely while ignoring many of the details of Windows programming.
Unfortunately, this added safety comes at the price of reduced flexibility and sometimes performance. Visual Basic makes it unnecessary to use many dangerous but powerful tools in the Windows Application Programming Interface (API). Sometimes, however, you may want to use those tools.
This chapter explains how you can use Windows API functions in your Visual Basic programs. It explains generally how to use the API and discusses the complexities of passing parameters to API functions. Later chapters have more to say about using particular functions.
The Genie
Using the API directly is like letting a genie out of a bottleyou gain access to tremendous power but at a substantial risk. Once you have finished, putting the genie back in the bottle may not be easy.
If you pass the wrong arguments to an API function, your program may generate a General Protection Fault (GPF). This will crash the program, probably the Visual Basic development environment, and possibly Windows as well. You will lose any work you have done since the last time you saved your files.

 
< previous page page_55 next page >